package com.qf.shop.user.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.shop.common.utils.PageUtils;
import com.qf.shop.common.utils.Query;

import com.qf.shop.user.dao.UserDao;
import com.qf.shop.user.entity.UserEntity;
import com.qf.shop.user.service.UserService;
import org.springframework.util.StringUtils;


@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //1.创建分页对象
        IPage<UserEntity> page1 = new Query<UserEntity>().getPage(params);
        //2.创建查询对象
        QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
        Object username = params.get("username");
        if (username!=null && !StringUtils.isEmpty(username.toString())){
            queryWrapper.like("username", username);
        }
        //3.组合条件查询
        IPage<UserEntity> page = this.page(page1, queryWrapper);

        return new PageUtils(page);
    }

}